Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @rdfjs/namespace #41082

Merged
merged 7 commits into from Dec 23, 2019

Conversation

thewilkybarkid
Copy link
Contributor

@thewilkybarkid thewilkybarkid commented Dec 17, 2019

Moved from rdfjs-base/namespace#5. (Tried to improve it a bit, still a little confused by CommonJS exports...)

  • 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.)
  • Add or edit tests to reflect the change. (Run with npm test.)
  • 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 already provide its own types, or cannot have its .d.ts files generated via --declaration
  • 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.
  • Represents shape of module/library correctly
  • tslint.json should be present and it shouldn't have any additional or disabling of rules. Just content as { "extends": "dtslint/dt.json" }. If for reason the some rule need to be disabled, disable it for that line using // tslint:disable-next-line [ruleName] and not for whole package so that the need for disabling can be reviewed.
  • tsconfig.json should have noImplicitAny, noImplicitThis, strictNullChecks, and strictFunctionTypes set to true.

@typescript-bot typescript-bot added this to Needs Author Attention in Pull Request Status Board Dec 17, 2019
@typescript-bot typescript-bot added New Definition This PR creates a new definition package. The Travis CI build failed labels Dec 17, 2019
@typescript-bot
Copy link
Contributor

typescript-bot commented Dec 17, 2019

@thewilkybarkid Thank you for submitting this PR!

Because this is a new definition, a DefinitelyTyped maintainer will be reviewing this PR in the next few days once the Travis CI build passes.

In the meantime, if the build fails or a merge conflict occurs, I'll let you know. Have a nice day!

@typescript-bot
Copy link
Contributor

@thewilkybarkid The Travis CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

@thewilkybarkid
Copy link
Contributor Author

Not sure what I'm doing wrong. Had problems with using dts-gen to create both the @rdfjs/namespace and rdfjs__namespace forms.

@typescript-bot
Copy link
Contributor

typescript-bot commented Dec 17, 2019

@thewilkybarkid The Travis CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

@thewilkybarkid thewilkybarkid mentioned this pull request Dec 17, 2019
12 tasks
@typescript-bot
Copy link
Contributor

👋 Hi there! I’ve run some quick measurements against master and your PR. These metrics should help the humans reviewing this PR gauge whether it might negatively affect compile times or editor responsiveness for users who install these typings.

Let’s review the numbers, shall we?

These typings are for a package that doesn’t yet exist on master, so I don’t have anything to compare against yet! In the future, I’ll be able to compare PRs to rdfjs__namespace with its source on master.

Comparison details 📊
Batch compilation
Type count 9440
Assignability cache size 3077
Language service measurements
Samples taken 36
Identifiers in tests 36
getCompletionsAtPosition
    Mean duration (ms) 358.0
    Mean CV 14.1%
    Worst duration (ms) 475.7
    Worst identifier NamedNode
getQuickInfoAtPosition
    Mean duration (ms) 355.5
    Mean CV 14.5%
    Worst duration (ms) 449.6
    Worst identifier NamedNode
System information
Node version v12.13.1
CPU count 2
CPU speed 2.294 GHz
CPU model Intel(R) Xeon(R) CPU E5-2673 v4 @ 2.30GHz
CPU Architecture x64
Memory 6.8 GiB
Platform linux
Release 4.15.0-1064-azure

@thewilkybarkid thewilkybarkid marked this pull request as ready for review December 17, 2019 14:31
Comment on lines +12 to +14
(property: TemplateStringsArray | string): NamedNode;

readonly [property: string]: NamedNode;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

My IDE (PhpStorm) complains if using the property name (confuses it with Function.name, so thinks it's a string instead).

TypeScript and eslint don't have the problem though; not sure if there's a way to keep both happy.

Edit: forgot this file wasn’t in the container I was running them through.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding an explicit name property gets round it, but should be unnecessary.

Copy link
Contributor

@tpluscode tpluscode Dec 20, 2019

Choose a reason for hiding this comment

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

My eslint setup complains about that name property. Here's another solution

type NamespaceBuilder = Record<string, NamedNode> & Omit<{
  (property: TemplateStringsArray | string): NamedNode;
}, 'name'>

EDIT: I inlined the interface to hide it from the implicit export

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, doesn't seem to work, no longer recognised as callable...

Choose a reason for hiding this comment

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

@thewilkybarkid I think it's unavoidable to redeclare the properties from the Function.prototype (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/prototype)

If Typescript did override, then it would have a knock on effect on things like objects:

type A = {
 [property: string]: SomeType;
};

const t: A = { };

t.toString(); // is this a function or `SomeType`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@typescript-bot typescript-bot added the Unmerged The author did not merge the PR when it was ready. label Dec 22, 2019
@typescript-bot
Copy link
Contributor

After 5 days, no one has reviewed the PR 😞. A maintainer will be reviewing the PR in the next few days and will either merge it or request revisions. Thank you for your patience!

@andrewbranch andrewbranch merged commit a9bf23a into DefinitelyTyped:master Dec 23, 2019
Pull Request Status Board automation moved this from Review to Done Dec 23, 2019
@typescript-bot
Copy link
Contributor

I just published @types/rdfjs__namespace@1.1.0 to npm.

@thewilkybarkid thewilkybarkid deleted the rdfjs__namespace branch December 23, 2019 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Definition This PR creates a new definition package. Unmerged The author did not merge the PR when it was ready.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants