mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
fix(npm): using types for packages with subpath (#16656)
For CommonJS packages we were not trying different extensions for files specified as subpath of the package ([package_name]/[subpath]). This commit fixes that.
This commit is contained in:
parent
bd159b8bad
commit
1416713cb3
11 changed files with 137 additions and 31 deletions
4
cli/tests/testdata/npm/registry/@denotest/types/1.0.0/index.d.ts
vendored
Normal file
4
cli/tests/testdata/npm/registry/@denotest/types/1.0.0/index.d.ts
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
export interface Fizzbuzz {
|
||||
fizz: string;
|
||||
buzz: string;
|
||||
}
|
5
cli/tests/testdata/npm/registry/@denotest/types/1.0.0/package.json
vendored
Normal file
5
cli/tests/testdata/npm/registry/@denotest/types/1.0.0/package.json
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"name": "@denotest/types-ambient",
|
||||
"version": "1.0.0",
|
||||
"types": "./index.d.ts"
|
||||
}
|
4
cli/tests/testdata/npm/registry/@denotest/types_imported/1.0.0/index.d.ts
vendored
Normal file
4
cli/tests/testdata/npm/registry/@denotest/types_imported/1.0.0/index.d.ts
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
export interface SomeInterface {
|
||||
prop: string;
|
||||
prop2: number;
|
||||
}
|
5
cli/tests/testdata/npm/registry/@denotest/types_imported/1.0.0/package.json
vendored
Normal file
5
cli/tests/testdata/npm/registry/@denotest/types_imported/1.0.0/package.json
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"name": "@denotest/types-ambient",
|
||||
"version": "1.0.0",
|
||||
"types": "./index.d.ts"
|
||||
}
|
4
cli/tests/testdata/npm/registry/@denotest/types_imported/1.0.0/subpath.d.ts
vendored
Normal file
4
cli/tests/testdata/npm/registry/@denotest/types_imported/1.0.0/subpath.d.ts
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
export interface Foobar {
|
||||
foo: string;
|
||||
bar: string;
|
||||
}
|
51
cli/tests/testdata/npm/types/main.out
vendored
Normal file
51
cli/tests/testdata/npm/types/main.out
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
error: TS2322 [ERROR]: Type 'number' is not assignable to type 'string'.
|
||||
bar: 1,
|
||||
~~~
|
||||
at [WILDCARD]/npm/types/main.ts:7:3
|
||||
|
||||
The expected type comes from property 'bar' which is declared here on type 'Foobar'
|
||||
bar: string;
|
||||
~~~
|
||||
at [WILDCARD]/@denotest/types_imported/1.0.0/subpath.d.ts:3:5
|
||||
|
||||
TS2322 [ERROR]: Type 'number' is not assignable to type 'string'.
|
||||
prop: 1,
|
||||
~~~~
|
||||
at [WILDCARD]/npm/types/main.ts:11:3
|
||||
|
||||
The expected type comes from property 'prop' which is declared here on type 'SomeInterface'
|
||||
prop: string;
|
||||
~~~~
|
||||
at [WILDCARD]/@denotest/types_imported/1.0.0/index.d.ts:2:5
|
||||
|
||||
TS2322 [ERROR]: Type 'string' is not assignable to type 'number'.
|
||||
prop2: "asdf",
|
||||
~~~~~
|
||||
at [WILDCARD]/npm/types/main.ts:12:3
|
||||
|
||||
The expected type comes from property 'prop2' which is declared here on type 'SomeInterface'
|
||||
prop2: number;
|
||||
~~~~~
|
||||
at [WILDCARD]/@denotest/types_imported/1.0.0/index.d.ts:3:5
|
||||
|
||||
TS2322 [ERROR]: Type 'number' is not assignable to type 'string'.
|
||||
fizz: 1,
|
||||
~~~~
|
||||
at [WILDCARD]/npm/types/main.ts:16:3
|
||||
|
||||
The expected type comes from property 'fizz' which is declared here on type 'Fizzbuzz'
|
||||
fizz: string;
|
||||
~~~~
|
||||
at [WILDCARD]/@denotest/types/1.0.0/index.d.ts:2:3
|
||||
|
||||
TS2322 [ERROR]: Type 'number' is not assignable to type 'string'.
|
||||
buzz: 2,
|
||||
~~~~
|
||||
at [WILDCARD]/npm/types/main.ts:17:3
|
||||
|
||||
The expected type comes from property 'buzz' which is declared here on type 'Fizzbuzz'
|
||||
buzz: string;
|
||||
~~~~
|
||||
at [WILDCARD]/@denotest/types/1.0.0/index.d.ts:3:3
|
||||
|
||||
Found 5 errors.
|
18
cli/tests/testdata/npm/types/main.ts
vendored
Normal file
18
cli/tests/testdata/npm/types/main.ts
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
import type { Fizzbuzz } from "npm:@denotest/types";
|
||||
import type { SomeInterface } from "npm:@denotest/types_imported";
|
||||
import type { Foobar as FooInterface } from "npm:@denotest/types_imported/subpath";
|
||||
|
||||
const foobar: FooInterface = {
|
||||
foo: "foo",
|
||||
bar: 1,
|
||||
};
|
||||
|
||||
const i: SomeInterface = {
|
||||
prop: 1,
|
||||
prop2: "asdf",
|
||||
};
|
||||
|
||||
const fizzbuzz: Fizzbuzz = {
|
||||
fizz: 1,
|
||||
buzz: 2,
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue