Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Added type definitions for @vimeo/player#15593

Merged
14 commits merged into
DefinitelyTyped:masterfrom
denisyilmaz:@vimeo/player
Apr 18, 2017
Merged

Added type definitions for @vimeo/player#15593
14 commits merged into
DefinitelyTyped:masterfrom
denisyilmaz:@vimeo/player

Conversation

@denisyilmaz
Copy link
Copy Markdown
Contributor

@denisyilmaz denisyilmaz commented Apr 3, 2017

Please fill in this template.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

If adding a new definition:

  • The package does not provide its own types, and you can not add them.
  • If this is for an NPM package, match the name. If not, do not conflict with the name of an NPM package.
  • Create it with dts-gen --dt, not by basing it on an existing project.
  • tslint.json should be present, and tsconfig.json should have noImplicitAny, noImplicitThis, and strictNullChecks set to true.

references #15571

@dt-bot
Copy link
Copy Markdown
Member

dt-bot commented Apr 3, 2017

@vimeo/player/index.d.ts

Checklist

@ghost
Copy link
Copy Markdown

ghost commented Apr 17, 2017

This should go in types/vimeo__player. See microsoft/TypeScript#15051.

@ghost ghost added the Revision needed This PR needs code changes before it can be merged. label Apr 17, 2017
@denisyilmaz
Copy link
Copy Markdown
Contributor Author

I tried as suggested. updated VSC Workspace to typescript 2.3.0. but scoped module is not found in my test.ts file. (with updated tsconfig to "baseUrl": "types" etc…).

@ghost
Copy link
Copy Markdown

ghost commented Apr 18, 2017

That feature won't be out until 2.3.1. This could either wait, or use declare module "@vimeo/player { }.
This branch now contains commits that aren't yours. Please rebase to include just your changes. (Be sure to make a backup first.)

waiting for typescript 2.3.1 for support of scoped packages
@denisyilmaz
Copy link
Copy Markdown
Contributor Author

thanks for the help. hope now it is as needed.

Comment thread vimeo__player/index.d.ts Outdated
// Project: https://github.com/vimeo/player.js
// Definitions by: Denis Yılmaz <https://github.com/denisyilmaz>, Felix Albert <[email protected]>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3.1
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should just be 2.3, and we'll always use the greatest minor version.

Comment thread package.json Outdated
"dtslint": "Microsoft/dtslint#production",
"types-publisher": "Microsoft/types-publisher#production"
"types-publisher": "Microsoft/types-publisher#production",
"typescript": "^2.3.0-dev.20170418"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't modify this file.

Comment thread vimeo__player/@vimeo-player-tests.ts Outdated
@@ -0,0 +1,456 @@
import { Player } from '@vimeo/player'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in types/vimeo__player/vimeo__player-tests.ts.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for confusion, just to be sure:
only the vimeo__player-tests.ts should be in the types/vimeo__player folder?
the vimeo__player/index.d.ts file stays in the main folder? It was suggested in a "contributor handbook", so I'm unsure whats the right way.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything should go in types/vimeo__player.

@denisyilmaz
Copy link
Copy Markdown
Contributor Author

travis failed: Could not parse version: line is '// TypeScript Version: 2.3'
should i just delete it for now till typescript 2.3 is out?

@ghost
Copy link
Copy Markdown

ghost commented Apr 18, 2017

Yes, and be sure to run npm run lint vimeo__player.

@denisyilmaz
Copy link
Copy Markdown
Contributor Author

hm, with npm run lint vimeo__player getting following error:

Warning: Text includes DefinitelyTyped link, but '--dt' is not set.
Failed to load /Users/[…]/types/vimeo__player/tslint.json: Invalid "extends" configuration value - could not require "dtslint/dt.json". Review the Node lookup algorithm (https://nodejs.org/api/modules.html#modules_all_together) for the approximate method TSLint uses to find the referenced configuration file.

@ghost
Copy link
Copy Markdown

ghost commented Apr 18, 2017

Looks like you're using an older version of dtslint, just reinstall.

@denisyilmaz
Copy link
Copy Markdown
Contributor Author

ok, reinstalled, but getting following error Object.entries is not a function

@ghost
Copy link
Copy Markdown

ghost commented Apr 18, 2017

Upgrade your node version too. It should have warned about that on install.

@denisyilmaz
Copy link
Copy Markdown
Contributor Author

I'm sorry for my inability to fix this. Finally resolved all errors except for:
ERROR: 6:1 no-single-declare-module File has only 1 module declaration — write it as an external module.

@ghost
Copy link
Copy Markdown

ghost commented Apr 18, 2017

Just add a // tslint:disable-next-line no-single-declare-module above the declare module, since you need it until 2.3.1 is published.

needed untill typescript 2.3.1 is out.
Comment thread types/vimeo__player/index.d.ts Outdated
@@ -0,0 +1,107 @@
// Type definitions for @vimeo/player 2.0
// Project: https: //github.com/vimeo/player.js
Copy link
Copy Markdown

@ghost ghost Apr 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space between https: and //

Comment thread types/vimeo__player/index.d.ts Outdated
// Definitions by: Denis Yılmaz <https: //github.com/denisyilmaz>, Felix Albert <[email protected]>
// Definitions: https: //github.com/DefinitelyTyped/DefinitelyTyped
// Project: https://github.com/vimeo/player.js
// Definitions by: Denis Yılmaz <mail@denisyilmaz.de>, Felix Albert <[email protected]>
Copy link
Copy Markdown

@ghost ghost Apr 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, a github username is better so we can notify you about issues and pull requests related to this package.

@ghost
Copy link
Copy Markdown

ghost commented Apr 18, 2017

Thanks!

@ghost ghost merged commit a209273 into DefinitelyTyped:master Apr 18, 2017
@denisyilmaz denisyilmaz deleted the @vimeo/player branch April 18, 2017 18:33
@denisyilmaz denisyilmaz restored the @vimeo/player branch April 18, 2017 18:33
@denisyilmaz denisyilmaz deleted the @vimeo/player branch April 18, 2017 19:00
@denisyilmaz
Copy link
Copy Markdown
Contributor Author

denisyilmaz commented Apr 18, 2017

Thanks a lot!
One last question: I tried adding the typings to my recent angular project. the types get recognized just fine, but on compiler time i get the /node_modules/@vimeo/player/dist/player.js' implicitly has an 'any' type. error…
I think it's because of the naming "vimeo__player".
should i open a new issue?

@ghost
Copy link
Copy Markdown

ghost commented Apr 18, 2017

It looks like module resolution for an import in your code resolved to a JS file and didn't find any declaration to resolve to.
If you tried importing e.g. import * as p from "@vimeo/player/dist/player", that would explain the problem since the type declaration here doesn't declare such a module; it just declares @vimeo/player.

@denisyilmaz
Copy link
Copy Markdown
Contributor Author

unfortunalty no. I'm importing the same way as in my test.ts file. import { Player } from '@vimeo/player';
VSC finds the installed typings correctly. I even added the "vimeo__player" to the compilerOptiony >> types.
Could not find a declaration file for module '@vimeo/player'. '/Users/[…]/frontend/node_modules/@vimeo/player/dist/player.js' implicitly has an 'any' type.

@denisyilmaz denisyilmaz restored the @vimeo/player branch April 18, 2017 19:59
@denisyilmaz
Copy link
Copy Markdown
Contributor Author

denisyilmaz commented Apr 18, 2017

ok, i looked at another type-definition and they made it like this:

typescriptdeclare namespace Player { }

declare module '@vimeo/player' {
	export = Player;
}

declare module '@vimeo/player/dist/player' {
	export = Player;
}

you think that would fix the problem?
In the "@vimeo/player" library itself the package.json defines "types": "dist/player"

@ghost
Copy link
Copy Markdown

ghost commented Apr 18, 2017

What other type definition? ❓
Try turning on --traceResolution to see where /node_modules/@vimeo/player/dist/player.js is getting imported in your code.

@denisyilmaz
Copy link
Copy Markdown
Contributor Author

in the @types/mapbox-gl they declare it this way

@ghost
Copy link
Copy Markdown

ghost commented Apr 18, 2017

Oh, thought you meant another definition for the same module.
For mapbox-gl they must have intended for someone to be able to import * as gl from "mapbox-gl/dist/mapbox-gl", but if you're not actually directly importing from there it shouldn't be relevant...

@denisyilmaz
Copy link
Copy Markdown
Contributor Author

Oh, no sorry for confusion. :)

i tried the traceResolution option, but it just shows the error in the component where I'm importing the "@vimeo/player"

Error at /Users/…/frontend/src/app/shared/vimeo-video/vimeo-video.component.ts:4:24: Could not find a declaration file for module '@vimeo/player'. '/Users/…/frontend/node_modules/@vimeo/player/dist/player.js' implicitly has an 'any' type.
Error at /Users/…/frontend/aot/src/app/shared/vimeo-video/vimeo-video.component.ngfactory.ts:12:26: Could not find a declaration file for module '@vimeo/player/dist/player'. '/Users/…/frontend/node_modules/@vimeo/player/dist/player.js' implicitly has an 'any' type.
Error at /Users/…/frontend/aot/src/app/page/main/element/element.component.ngfactory.ts:16:26: Could not find a declaration file for module '@vimeo/player/dist/player'. '/Users/…/frontend/node_modules/@vimeo/player/dist/player.js' implicitly has an 'any' type.

I'm nowhere declaring /dist/player.js to be imported, so it must happen in-between.
the only place I find /dist/player.js is in the plugin itself in the package.json '"types": "dist/player"'

{
  "compilerOptions": {
    "target": "es5",
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": ["es2015", "dom"],
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true,
    "types": [
      "node",
      "clipboard",
      "vimeo__player"
    ]
  },

  "files": [
    "src/app/app.module.ts",
    "src/main-aot.ts"
  ],

  "angularCompilerOptions": {
   "genDir": "aot",
   "skipMetadataEmit" : true
 }
}

@ghost
Copy link
Copy Markdown

ghost commented Apr 18, 2017

It looks like module resolution is correctly resolving it as a JS module, but only because it didn't find the types first. Are you sure you've correctly included those types? --listFiles would show you if it's lincluded.

@ghost
Copy link
Copy Markdown

ghost commented Jun 15, 2017

@rugdealer That looks like a run-time error, not a compile error.

@denisyilmaz
Copy link
Copy Markdown
Contributor Author

denisyilmaz commented Jun 16, 2017

Actually we had similar problems with it. I think the problem could be found here https://github.com/vimeo/player.js#using-with-a-module-bundler >> window.Vimeo

Is there a way we could add the Vimeo-Namespace but still using this.player = new Player(…)?

The Vimeo-API Sets a global Vimeo Namespace in which the Player Class exist. Typings for Vimeo.Player would cause typescript compiler to fail with error, Typings for Player fail on runtime…

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Revision needed This PR needs code changes before it can be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants