Commit graph

38 commits

Author SHA1 Message Date
Dunqing
3d29e9cb75 fix(isolated-declarations): eliminate imports incorrectly when they are used in TSInferType (#4043)
close: #4018
2024-07-03 15:32:27 +00:00
Egor Blinov
7768d233c6
feat(isolated-declarations): support optional class methods (#4035)
Example class
```
export class A {
  m1?(): void;
  m2(): void {}
}
```

Before the fix:
```
export declare class A {
  m1(): void;
}
```

with the fix:
```
export declare class A {
  m1?(): void;
  m2(): void;
}
```
2024-07-03 09:46:59 +08:00
Egor Blinov
c043bec674
fix(isolated_declarations): add mapped-type constraint to the scope (#4037)
Fixes https://github.com/oxc-project/oxc/issues/4020

Example:
```ts
import {K} from 'foo'
import {T} from 'bar'

export interface I {
    prop: {[key in K]: T}
}
```

Before:
```ts
import {T} from 'bar'
export interface I {
    prop: {[key in K]: T}
}
```

After:
```ts
import {K} from 'foo'
import {T} from 'bar'
export interface I {
    prop: {[key in K]: T}
}
```

TSC:
```ts
import { K } from 'foo';
import { T } from 'bar';
export interface I {
    prop: {
        [key in K]: T;
    };
}

```
2024-07-03 09:45:03 +08:00
Egor Blinov
b007553ebe
fix(isolated_declarations): Fix readonly specifier on class constructor params (#4030) 2024-07-02 23:26:19 +08:00
Egor Blinov
da628399fa
fix(isolated_declarations): inferring literal types for readonly class fileds (#4027) 2024-07-02 23:00:37 +08:00
Dunqing
02ea19a3b7 fix(isolated-declarations): should emit export {} when only having ImportDeclaration (#4026)
close: #4023
2024-07-02 13:47:30 +00:00
Dunqing
7c915f4665 fix(isolated-declarations): binding elements with export should report an error (#4025)
close: #3976
2024-07-02 13:47:28 +00:00
Dunqing
05a047c17d fix(isolated-declarations): method following an abstract method gets dropped (#4024)
close: #4019
2024-07-02 13:47:26 +00:00
Dunqing
bd1141da67 fix(isolated-declarations): if declarations is referenced in declare global then keep it (#3982)
close: #3981
2024-06-30 11:34:04 +00:00
Boshen
dc6d45e2e6 feat(ast,codegen): add TSParenthesizedType and print type parentheses correctly (#3979)
closes #3916
2024-06-30 07:57:48 +00:00
Dunqing
51e54f902c fix(codegen): should print TSModuleDeclarationKind instead of just module (#3957) 2024-06-29 05:24:36 +00:00
Dunqing
31e4c3b33e fix(isolated-declarations): declare global {} should be kept even if it is not exported (#3956)
close: #3952
2024-06-29 05:07:21 +00:00
Dunqing
27665945f1 fix(codegen): print type parameters for MethodDefinition (#3922)
close: #3918
2024-06-26 07:21:42 +00:00
Dunqing
27f0531aac fix(isolated-declarations): private constructor reaching unreachable (#3921)
fix: #3917
2024-06-26 07:21:38 +00:00
Dunqing
59ce38bb85 fix(isolated-declarations): inferring of UnrayExpression incorrectly (#3920)
close: #3914
2024-06-26 07:21:35 +00:00
Dunqing
5e2baf3edd feat(isolated-declarations): report error for expando functions (#3872)
close: #3703
2024-06-24 10:56:23 +00:00
Boshen
777f12b6fd
chore(isolated-declarations): run integration tests only once 2024-06-24 00:24:16 +08:00
Dunqing
2cdb34f6df feat(isolated-declarations): support for class function overloads (#3811) 2024-06-21 14:37:10 +00:00
Dunqing
58e54f4aea fix(isolated-declarations): report an error for parameters if they are ObjectPattern or ArrayPattern without an explicit type (#3810) 2024-06-21 10:20:28 +00:00
Dunqing
231b8f0946 feat(isolated-declarations): support for export default function overloads (#3809) 2024-06-21 10:20:25 +00:00
Dunqing
eadf495e85 chore(isolated-declarations): add tests from Deno (#3808) 2024-06-21 10:20:21 +00:00
Dunqing
a37138f1ec feat(isolated-declarations): improve the inference template literal (#3797) 2024-06-20 15:02:45 +00:00
Dunqing
b0d7355c98 feat(isolated-declarations): transform const expression correctly (#3793) 2024-06-20 15:02:41 +00:00
Dunqing
2821e0e307 feat(codegen): print readonly keyword for TSIndexSignature (#3791) 2024-06-20 10:13:51 +00:00
Dunqing
7d47fc3fcc fix(isolated-declarations): should stripe async and generator keyword after transformed (#3790) 2024-06-20 10:13:44 +00:00
Dunqing
97575d8cab feat(codegen): print TSClassImplements and TSThisParameter (#3786)
close: https://github.com/oxc-project/oxc/issues/3692#issuecomment-2178994839
2024-06-20 06:15:23 +00:00
Dunqing
497769cb60 feat(ast): add some visitor functions (#3785) 2024-06-20 05:23:04 +00:00
Dunqing
b38c34dfce feat(isolated-declarations): support inferring ParenthesizedExpression (#3769) 2024-06-19 15:43:21 +00:00
Dunqing
8ce794d740 fix(isolated-declarations): inferring an incorrect return type when there is an arrow function inside a function (#3768) 2024-06-19 15:43:15 +00:00
Dunqing
4134de8dcf feat(isolated-declarations): add ts error code to the error message (#3755) 2024-06-19 14:33:29 +00:00
Dunqing
94202de250 feat(isolated-declarations): add export {} when needed (#3754)
https://github.com/microsoft/TypeScript/pull/58912
2024-06-19 14:33:27 +00:00
Dunqing
d29316a5ff fix(isolated-declarations): transform incorrectly when there are multiple functions with the same name (#3753) 2024-06-19 14:33:25 +00:00
Dunqing
e95d8e3990 feat(isolated-declarations): shrink span for arrow function that needs an explicit return type (#3752)
Current `span` we can't be consistent with typescript.

We report the following
```ts
(a, b) =>
^^^^^^^^^
{ }
^
```

TypeScript reports the following
```ts
(a, b) =>
^^^^^^^^^
{}
```

The TypeScript only reports the first line, if we want it to be exactly the same we need to find the first newline position
2024-06-19 14:33:24 +00:00
Dunqing
bf1c250d56 fix(isolated-declarations): false positives for non-exported binding elements (#3751) 2024-06-19 14:06:08 +00:00
Dunqing
df9971da4c feat(isolated-declarations): improve inferring the return type from function (#3750) 2024-06-19 14:06:05 +00:00
Dunqing
4aea2b158c feat(isolated-declarations): improve inferring the type of accessor (#3749) 2024-06-19 14:06:02 +00:00
Dunqing
9ea30c41ff feat(isolated-declarations): treat AssignmentPattern as optional (#3748) 2024-06-19 14:05:59 +00:00
Boshen
8c02c1dac3 chore(isolated-declarations): add snapshot testing (#3756) 2024-06-19 09:20:17 +00:00