Comments (10)
@andrewbranch @RyanCavanaugh @DanielRosenwasser in case you're interested or have opinions.
from types-publisher.
Everything else should be referenced either through index.d.ts or through an explicit reference in the tests.
Better make that a rule too! No ignored .d.ts
files.
from types-publisher.
this doesn't reflect how users will reference the type files as installed in @types/*.
incorrectly able to resolve
glo
Just to clarify, you’re implicitly referring to the fact that the compiler’s resolution rules use only the @types package’s index.d.ts
as an entry point (or more accurately, it will follow the package.json types
field, which is already enforced to be index.d.ts
by types-publisher), correct? So the goal is to make resolution the same for tests as it is for users.
from types-publisher.
Assuming I understood that right, this sounds like a good idea.
from types-publisher.
@DanielRosenwasser types-publisher's checks are already pretty strict about ignoring files. There are a lot of quasi-ignored files that will move from tsconfig to OTHER_FILES.txt as part of this change. I think it's important to have an opt-out so that people don't have to test their types exhaustively, but it's also important that those opted-out files look different.
@andrewbranch You are right.
from types-publisher.
I actually tried to explicitly declare /// <reference types="*"/>
in my UMD @types
definitions, but dtslint
complained that it’s unnecessary and caused build failures.
from types-publisher.
"*"
? That is equivalent to import "*"
-- I don't think it resolves to anything.
from types-publisher.
import "*"
makes the file be parsed as a module, thus making the UMD export as namespace
inaccessible.
/// <reference types="*">
keeps the file parsed as is, and with no import
or export
s, UMD export as namespace
definitions are accessible.
"*"
in this context means "<module_name>"
.
Example:
types/foo/index.d.ts
:
declare function foo(…): …;
export as namespace foo;
export = foo;
types/foo/test/foo.umd.test.ts
:
/// <reference types="foo">
// the above line causes a types-publisher failure, since `foo/index.d.ts`
// is in scope through `tsconfig.json#/files`
foo(…); // $ExpectType …
types/foo/test/foo.cjs.test.ts
:
import fooImport = require('foo');
fooImport(…); // $ExpectType …
// The `foo` UMD export is correctly inaccessible in CommonJS files:
foo; // $ExpectError
from types-publisher.
Oh, I see. I didn't get the meaning of *
before.
Even after closing this issue, index.d.ts
has special handling and is implicitly included, as your example shows, even when it's not correct. I'm not sure how to fix that. We'd have to make it inaccessible only to tests of globals, not of modules.
from types-publisher.
Actually, it’s types‑publisher
that doesn’t like <reference />
to self in UMD tests, which is why I couldn’t reproduce this locally (since types‑publisher
doesn’t like my environment for whatever reason, and therefore I run dtslint
directly).
All it takes is for #714 to be merged now, and my above example should become allowed.
from types-publisher.
Related Issues (20)
- Please add vue-property-decorator to the whitelist HOT 7
- Please make `checkTypeScriptVersions` aggregate version mismatches
- Scoped & versioned packages can't pass path mappings checks
- Resurrect crawl-npm.ts
- Improve notNeededPackages.json testing HOT 1
- Update outdated packages HOT 1
- testDependencies should include only top-level package names HOT 1
- publish-registry validation fails when new packages are out but we won't publish them for a week
- Changes published from DefinitelyTyped are not marked as 'latest' HOT 1
- 'download' is not allowed in new npm package names
- Can't unpublish fastify-static HOT 2
- Deprecated packages often fail to publish correctly
- types-publisher is crashing during indexing HOT 3
- Optional catch binding in util.ts is failing PRs on DefinitelyTyped
- Error running tests (Error: Unexpected path .DS_Store) HOT 1
- Tests do not run reliably on Windows
- getLatestMatch throws "Could not find version [object Object]"
- Dependencies information in NPM registry saved with "^[object Object]" value HOT 1
- typesVersions gets mangled in the published package HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from types-publisher.