mirror of
https://gitee.com/openharmony/third_party_typescript
synced 2024-11-27 00:51:12 +00:00
add TS5.0's feature
Issue:https://gitee.com/openharmony/third_party_typescript/issues/I9HHI4 Test:ts extra test Signed-off-by: liujia178 <liujia178@huawei.com>
This commit is contained in:
parent
9c65d3e363
commit
52ee9575e4
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 manages to make all enums into union enums by creating a unique type for each computed member.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
enum Color {
|
||||
Red,
|
||||
Orange,
|
||||
Yellow,
|
||||
Green,
|
||||
Blue,
|
||||
Violet
|
||||
}
|
||||
|
||||
type PrimaryColor = Color.Red | Color.Green | Color.Blue;
|
||||
|
||||
function isPrimaryColor(c: Color): c is PrimaryColor {
|
||||
return (c === Color.Red || c === Color.Green || c === Color.Blue);
|
||||
}
|
||||
|
||||
const blueColor = isPrimaryColor(Color.Blue);
|
||||
Assert.isTrue(blueColor);
|
||||
|
||||
const yellowColor = isPrimaryColor(Color.Yellow);
|
||||
Assert.isFalse(yellowColor);
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 manages to make all enums into union enums by creating a unique type for each computed member.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
enum binary {
|
||||
A = 1011 + 'abc',
|
||||
B = 110 + 'bcd',
|
||||
C = 101 + 'cde'
|
||||
}
|
||||
|
||||
type myBinary = binary.A | binary.B;
|
||||
|
||||
function isMyBinary(c: binary): c is myBinary {
|
||||
return (c === binary.A || c === binary.B);
|
||||
}
|
||||
|
||||
Assert.isTrue(isMyBinary(binary.B));
|
||||
Assert.isFalse(isMyBinary(binary.C));
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 manages to make all enums into union enums by creating a unique type for each computed member.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
const enum Values {
|
||||
First = 'aaaaa',
|
||||
Second = 'bbbbbbbbb',
|
||||
Third = 'ccccccccc'
|
||||
}
|
||||
|
||||
type PrimaryValues = Values.First | Values.Second;
|
||||
|
||||
function isPrimaryValues(c: Values): c is PrimaryValues {
|
||||
return c === Values.First || c === Values.Second;
|
||||
}
|
||||
|
||||
const firstValue = isPrimaryValues(Values.First);
|
||||
Assert.isTrue(firstValue);
|
||||
|
||||
const secondValue = isPrimaryValues(Values.Third);
|
||||
Assert.isFalse(secondValue);
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 manages to make all enums into union enums by creating a unique type for each computed member.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
const enum Values {
|
||||
a = 3 / 2,
|
||||
b = 5 + 1,
|
||||
c = 1 * 3
|
||||
}
|
||||
|
||||
type PrimaryValues = Values.a | Values.b;
|
||||
|
||||
function isPrimaryValues(c: Values): c is PrimaryValues {
|
||||
return c === Values.a || c === Values.b;
|
||||
}
|
||||
|
||||
const firstValue = isPrimaryValues(Values.a);
|
||||
Assert.isTrue(firstValue);
|
||||
|
||||
const secondValue = isPrimaryValues(Values.c);
|
||||
Assert.isFalse(secondValue);
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 manages to make all enums into union enums by creating a unique type for each computed member.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
enum Color {
|
||||
Red,
|
||||
Orange,
|
||||
Yellow,
|
||||
Green,
|
||||
Blue,
|
||||
Violet
|
||||
}
|
||||
|
||||
enum Values {
|
||||
First = 'aaaaa',
|
||||
Second = 'bbbbbbbbb',
|
||||
Third = 'ccccccccc'
|
||||
}
|
||||
|
||||
type PrimaryValues = Color.Red | Values.First;
|
||||
|
||||
function isPrimaryValues(c: Values | Color): c is PrimaryValues {
|
||||
return c === Color.Red || c === Values.First;
|
||||
}
|
||||
|
||||
const firstValue = isPrimaryValues(Values.First);
|
||||
Assert.isTrue(firstValue);
|
||||
|
||||
const secondValue = isPrimaryValues(Color.Red);
|
||||
Assert.isTrue(secondValue);
|
||||
|
||||
const thirdValue = isPrimaryValues(Color.Yellow);
|
||||
Assert.isFalse(thirdValue);
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 manages to make all enums into union enums by creating a unique type for each computed member.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
enum E {
|
||||
A = 10 * 10, // Numeric literal enum member
|
||||
B = 'foo', // String literal enum member
|
||||
C = Math.random() // Opaque computed enum member
|
||||
}
|
||||
|
||||
function getStringValue(e: E): string {
|
||||
return String(e);
|
||||
}
|
||||
|
||||
Assert.equal(getStringValue(E.A), 100);
|
||||
Assert.equal(getStringValue(E.B), 'foo');
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 manages to make all enums into union enums by creating a unique type for each computed member.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
enum ShapeKind {
|
||||
Circle,
|
||||
Square,
|
||||
Star
|
||||
}
|
||||
|
||||
interface Circle {
|
||||
kind: ShapeKind.Circle;
|
||||
radius: number;
|
||||
}
|
||||
|
||||
interface Square {
|
||||
kind: ShapeKind.Square;
|
||||
sideLength: number;
|
||||
}
|
||||
|
||||
interface Star {
|
||||
kind: ShapeKind.Star;
|
||||
sideLength: number;
|
||||
}
|
||||
|
||||
type values = ShapeKind.Circle | ShapeKind.Square;
|
||||
function getStringValue(c: ShapeKind): c is values {
|
||||
return c === ShapeKind.Circle || c === ShapeKind.Square;
|
||||
}
|
||||
|
||||
Assert.isTrue(getStringValue(ShapeKind.Circle));
|
||||
Assert.isTrue(getStringValue(ShapeKind.Square));
|
||||
Assert.isFalse(getStringValue(ShapeKind.Star));
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 manages to make all enums into union enums by creating a unique type for each computed member.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
enum AnimalFlags {
|
||||
None = 0,
|
||||
HasClaws = 1 << 0,
|
||||
CanFly = 1 << 1,
|
||||
EatsFish = 1 << 2,
|
||||
Endangered = 1 << 3,
|
||||
EndangeredFlyingClawedFishEating = HasClaws | CanFly | EatsFish | Endangered
|
||||
}
|
||||
|
||||
Assert.equal(AnimalFlags.EndangeredFlyingClawedFishEating, 15);
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 manages to make all enums into union enums by creating a unique type for each computed member.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
const enum Foo { Value = 0x01 }
|
||||
const enum Bar { Value = 0x02 }
|
||||
const enum Baz { Value = Foo.Value | Bar.Value }
|
||||
|
||||
Assert.equal(Baz.Value, 3);
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 manages to make all enums into union enums by creating a unique type for each computed member.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
const prefix = '/demo';
|
||||
|
||||
enum Routes {
|
||||
src = `${prefix}/src`, // "/demo/src"
|
||||
tsdemo = `${prefix}/tsdemo`, // "/demo/tsdemo"
|
||||
dist = `${prefix}/dist` // "/demo/dist"
|
||||
}
|
||||
|
||||
type value = Routes.src | Routes.tsdemo;
|
||||
|
||||
function isRoutes(c: Routes): c is value {
|
||||
return (c === Routes.src || c === Routes.tsdemo);
|
||||
}
|
||||
|
||||
Assert.isTrue(isRoutes(Routes.src));
|
||||
Assert.isFalse(isRoutes(Routes.dist));
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
In TypeScript 5.0, you can now add a const modifier to a type parameter declaration to cause const-like
|
||||
inference to be the default.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
error: { code: Cannot assign to '0' because it is a read-only property }
|
||||
---*/
|
||||
|
||||
|
||||
function value<const T>(arg: T): T {
|
||||
return arg;
|
||||
}
|
||||
|
||||
const myNames = value(['Jack', 'Bob', 'Eve']);
|
||||
myNames[0] = '1';// Cannot assign to '0' because it is a read-only property
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
In TypeScript 5.0, you can now add a const modifier to a type parameter
|
||||
declaration to cause const-like inference to be the default.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function constObjectTest<const T extends object>(args: T): T {
|
||||
return args;
|
||||
};
|
||||
const myObject = { key: 1, value: 'abc' };
|
||||
|
||||
let myObj = constObjectTest(myObject);
|
||||
Assert.equal(myObj.key, 1);
|
||||
Assert.equal(myObj.value, 'abc');
|
||||
|
||||
|
||||
myObj.key = 2;
|
||||
Assert.equal(myObj.key, 2);
|
||||
Assert.equal(myObj.value, 'abc');
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
In TypeScript 5.0, you can now add a const modifier to a type parameter declaration to cause
|
||||
const-like inference to be the default.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
error: { code: Cannot assign to '0' because it is a read-only property. }
|
||||
---*/
|
||||
|
||||
|
||||
function getValue<const T>(arg: T): T {
|
||||
return arg;
|
||||
}
|
||||
|
||||
const result = getValue({ name: 'Jack', frd: ['Bob', 'Eve'] });
|
||||
result.frd[0] = 'Sophia'; // Cannot assign to '0' because it is a read-only property
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
In TypeScript 5.0, you can now add a const modifier to a type parameter declaration to
|
||||
cause const-like inference to be the default.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
error: { code: Cannot assign to '0' because it is a read-only property. }
|
||||
---*/
|
||||
|
||||
|
||||
function getConstValue<const T>(arg: T): T {
|
||||
return arg;
|
||||
}
|
||||
|
||||
let val = getConstValue(['a' + 'b', 'cc']);
|
||||
val[0] = 'c'; // Cannot assign to '0' because it is a read-only property
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
In TypeScript 5.0, you can now add a const modifier to a type parameter declaration to
|
||||
cause const-like inference to be the default.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
error: { code: Cannot assign to '0' because it is a read-only property. }
|
||||
---*/
|
||||
|
||||
|
||||
function getFruit<const T>(arg: T): T {
|
||||
return arg;
|
||||
}
|
||||
|
||||
const myFruit = getFruit({ shop: 'Jack`s' + ' shop', fruit: ['apple', 'orange'] });
|
||||
myFruit.fruit[0] = 'Sophia'; // Cannot assign to '0' because it is a read-only property
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
In TypeScript 5.0, you can now add a const modifier to a type parameter declaration to
|
||||
cause const-like inference to be the default.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
error: { code: Cannot assign to '0' because it is a read-only property. }
|
||||
---*/
|
||||
|
||||
|
||||
type HasNames = { names: readonly string[] };
|
||||
function getNamesExactly<const T extends HasNames>(arg: T): T['names'] {
|
||||
return arg.names;
|
||||
}
|
||||
|
||||
let names = getNamesExactly({ names: ['Alice', 'Bob', 'Eve'] });
|
||||
names[0] = 'jack'; // Cannot assign to '0' because it is a read-only property
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
In TypeScript 5.0, you can now add a const modifier to a type parameter declaration to
|
||||
cause const-like inference to be the default.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
error: { code: Cannot assign to 'x' because it is a read-only property. }
|
||||
---*/
|
||||
|
||||
|
||||
function getNamesObject<const T extends object>(arg: T): T {
|
||||
return arg;
|
||||
}
|
||||
|
||||
let objectNames = getNamesObject({ x: 1, y: 1 });
|
||||
objectNames.x = 2; // Cannot assign to 'x' because it is a read-only property
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
In TypeScript 5.0, you can now add a const modifier to a type parameter declaration to
|
||||
cause const-like inference to be the default.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
error: { code: Cannot assign to '0' because it is a read-only property. }
|
||||
---*/
|
||||
|
||||
|
||||
function getNames<const T extends readonly string[]>(arg: T): T {
|
||||
return arg;
|
||||
}
|
||||
|
||||
let newNames = getNames(['a' + 'b', 'cc']);
|
||||
newNames[0] = 'jack'; // Cannot assign to '0' because it is a read-only property
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
In TypeScript 5.0, you can now add a const modifier to a type parameter
|
||||
declaration to cause const-like inference to be the default.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
error: { code: Cannot assign to '0' because it is a read-only property. }
|
||||
---*/
|
||||
|
||||
|
||||
function fruit<const T extends object>(arg: T): T {
|
||||
return arg;
|
||||
}
|
||||
|
||||
const getMyFruit = fruit({ shop: 'Jack`s' + ' shop', fruit: ['apple', 'orange'] });
|
||||
getMyFruit.fruit[0] = 'Sophia'; // Cannot assign to '0' because it is a read-only property
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
In TypeScript 5.0, you can now add a const modifier to a type
|
||||
parameter declaration to cause const-like inference to be the default.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function constTest<const T extends readonly string[]>(args: T): T {
|
||||
return args;
|
||||
};
|
||||
|
||||
const myString = ['a', 'b', 'c'];
|
||||
|
||||
let myArr = constTest(myString);
|
||||
Assert.equal(myArr[2], 'c');
|
||||
|
||||
myArr[2] = 'd';
|
||||
Assert.equal(myArr[2], 'd');
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
Class Decorator:
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function Greeter(value: Function, context: { kind: string }) {
|
||||
if (context.kind === 'class') {
|
||||
value.prototype.greet = function () {
|
||||
return 'hello';
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Greeter
|
||||
class User {
|
||||
greet(){
|
||||
return 'hi';
|
||||
}
|
||||
}
|
||||
|
||||
let u = new User();
|
||||
Assert.equal(u.greet(), 'hello');
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
Class Decorator:making classes function-callable
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function logged(value: any, context: { kind: string }) {
|
||||
if (context.kind === 'field') {
|
||||
return function (initialValue: number) {
|
||||
return initialValue = 2;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class C {
|
||||
@logged x = 1;
|
||||
}
|
||||
|
||||
Assert.equal(new C().x, 2);
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
Method Decorator:tracing method invocations
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function replaceMethod(value: Function, context: { kind: string }) {
|
||||
if (context.kind === 'method') {
|
||||
return function () {
|
||||
return 'How are you?';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Person {
|
||||
name: string;
|
||||
constructor(name: string) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@replaceMethod
|
||||
hello() {
|
||||
return `Hi ${this.name}!`;
|
||||
}
|
||||
}
|
||||
|
||||
const robin = new Person('Robin');
|
||||
Assert.equal(robin.hello(), 'How are you?');
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
Method Decorator:binding methods to instances
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function bind(value: Function, context: { kind: string, name: string, addInitializer(initializer: () => void): void }) {
|
||||
if (context.kind === 'method') {
|
||||
context.addInitializer(function (this: any) {
|
||||
this[context.name] = value.bind(this);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class Color {
|
||||
name: string;
|
||||
|
||||
constructor(myName: string) {
|
||||
this.name = myName;
|
||||
}
|
||||
|
||||
@bind
|
||||
toString() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
const green = new Color('green').toString;
|
||||
Assert.equal(green(), 'green');
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
Method Decorator:tracing method invocations
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function trace(value: Function, context: { kind: string }) {
|
||||
if (context.kind === 'method') {
|
||||
return function (this: any, ...args: any[]) {
|
||||
const result = value.apply(this, args) + '!!!';
|
||||
return result;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class StringBuilder {
|
||||
str = '';
|
||||
|
||||
@trace
|
||||
add(newStr: string) {
|
||||
this.str += newStr;
|
||||
}
|
||||
|
||||
@trace
|
||||
toString() {
|
||||
return this.str;
|
||||
}
|
||||
}
|
||||
|
||||
const sb = new StringBuilder();
|
||||
sb.add('Home');
|
||||
sb.add('page');
|
||||
|
||||
Assert.equal(sb.toString(), 'Homepage!!!');
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
Method Decorator:Class getter decorators
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function lazy(value: Function, context: { kind: string, name: string }) {
|
||||
if (context.kind === 'getter') {
|
||||
return function (this: object) {
|
||||
const result = value.call(this);
|
||||
Object.defineProperty(
|
||||
this, context.name,
|
||||
{
|
||||
value: result,
|
||||
writable: false
|
||||
}
|
||||
);
|
||||
return 'This is result.';
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class C {
|
||||
@lazy
|
||||
get value() {
|
||||
return 'Result of computation';
|
||||
}
|
||||
}
|
||||
|
||||
const inst = new C();
|
||||
Assert.equal(inst.value, 'This is result.');
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
Method Decorator:Class setter decorators
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function logged(value: Function, context: { kind: string }) {
|
||||
if (context.kind === 'setter') {
|
||||
return function (this: any, ...args: any[]) {
|
||||
const ret = value.call(this, ...args);
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class A {
|
||||
public value: number = 0;
|
||||
|
||||
@logged
|
||||
set x(newValue) {
|
||||
this.value = newValue;
|
||||
}
|
||||
|
||||
get x() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
const X = new A();
|
||||
X.x = 1;
|
||||
Assert.equal(X.value, 1);
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
Property Decorator(field):changing initialization values of fields
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function twice(value: undefined, context: { kind: string }) {
|
||||
if (context.kind === 'field') {
|
||||
return (initialValue: number) => initialValue * 2;
|
||||
}
|
||||
}
|
||||
|
||||
class test {
|
||||
@twice
|
||||
x = 2;
|
||||
}
|
||||
|
||||
let p = new test();
|
||||
Assert.equal(p.x, 4);
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
Property Decorator(field):static public fields(It cannot change or replace its field)
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function enumEntry(value: undefined, context: { kind: string, name: string }) {
|
||||
if (context.kind === 'field') {
|
||||
console.log(`starting ${context.name}`);
|
||||
}
|
||||
}
|
||||
|
||||
class colorClass {
|
||||
@enumEntry
|
||||
static red = 'red';
|
||||
}
|
||||
|
||||
Assert.equal(colorClass.red, 'red');
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
Accessor Decorator
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function accessorDecorator(value: any, { kind }: { kind: string }) {
|
||||
if (kind === 'accessor') {
|
||||
let { get, set } = value;
|
||||
|
||||
return {
|
||||
get() {
|
||||
return get.call(this);
|
||||
},
|
||||
|
||||
set(val: number) {
|
||||
Assert.equal(val, 123);
|
||||
return set.call(this, val);
|
||||
},
|
||||
|
||||
init(initialValue: number) {
|
||||
Assert.equal(initialValue, 1);
|
||||
return initialValue;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class accessorTest {
|
||||
@accessorDecorator
|
||||
accessor x = 1;
|
||||
}
|
||||
|
||||
let d = new accessorTest();
|
||||
d.x;
|
||||
d.x = 123;
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
In TypeScript 5.0, Check implicit type conversion of relational operator > < <= >=, prompt type error.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
error: { code: Operator '>' cannot be applied to types 'string | number' and 'number' }
|
||||
---*/
|
||||
|
||||
|
||||
function func(ns: number | string) {
|
||||
return ns > 4; // Operator '>' cannot be applied to types 'string | number' and 'number'
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
In TypeScript 5.0, Check implicit type conversion of relational operator > < <= >=, prompt type error.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function funcK(ns: number | string) {
|
||||
return -ns < 4;
|
||||
}
|
||||
|
||||
Assert.equal(funcK(2), true);
|
||||
Assert.equal(funcK(-6), false);
|
||||
Assert.equal(funcK('abc'), false);
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
In TypeScript 5.0, Check implicit type conversion of relational operator > < <= >=, prompt type error.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
error: { code: Operator '<' cannot be applied to types 'string | number' and 'number' }
|
||||
---*/
|
||||
|
||||
|
||||
function funcA(ns: number | string) {
|
||||
return ns < 4; // Operator '<' cannot be applied to types 'string | number' and 'number'
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
In TypeScript 5.0, Check implicit type conversion of relational operator > < <= >=, prompt type error.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
error: { code: Operator '<=' cannot be applied to types 'string | number' and 'number' }
|
||||
---*/
|
||||
|
||||
|
||||
function funcB(ns: number | string) {
|
||||
return ns <= 4; // Operator '<=' cannot be applied to types 'string | number' and 'number'
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
In TypeScript 5.0, Check implicit type conversion of relational operator > < <= >=, prompt type error.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
error: { code: Operator '>=' cannot be applied to types 'string | number' and 'number' }
|
||||
---*/
|
||||
|
||||
|
||||
function funcC(ns: number | string) {
|
||||
return ns >= 4; // Operator '>=' cannot be applied to types 'string | number' and 'number'
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
In TypeScript 5.0, Check implicit type conversion of relational operator > < <= >=, prompt type error.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function funcD(ns: number | string) {
|
||||
return +ns > 4;
|
||||
}
|
||||
|
||||
Assert.equal(funcD(2), false);
|
||||
Assert.equal(funcD(8), true);
|
||||
Assert.equal(funcD('abc'), false);
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
In TypeScript 5.0, Check implicit type conversion of relational operator > < <= >=, prompt type error.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function funcE(ns: number | string) {
|
||||
return +ns < 4;
|
||||
}
|
||||
|
||||
Assert.equal(funcE(5), false);
|
||||
Assert.equal(funcE(3), true);
|
||||
Assert.equal(funcE('abc'), false);
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
In TypeScript 5.0, Check implicit type conversion of relational operator > < <= >=, prompt type error.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function funcF(ns: number | string) {
|
||||
return +ns <= 4;
|
||||
}
|
||||
|
||||
Assert.equal(funcF(5), false);
|
||||
Assert.equal(funcF(4), true);
|
||||
Assert.equal(funcF('abc'), false);
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
In TypeScript 5.0, Check implicit type conversion of relational operator > < <= >=, prompt type error.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function funcG(ns: number | string) {
|
||||
return +ns >= 4;
|
||||
}
|
||||
|
||||
Assert.equal(funcG(2), false);
|
||||
Assert.equal(funcG(4), true);
|
||||
Assert.equal(funcG('abc'), false);
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
In TypeScript 5.0, Check implicit type conversion of relational operator > < <= >=, prompt type error.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function funcH(ns: number | string) {
|
||||
return -ns > 4;
|
||||
}
|
||||
|
||||
Assert.equal(funcH(2), false);
|
||||
Assert.equal(funcH(-6), true);
|
||||
Assert.equal(funcH('abc'), false);
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 now allows JSDoc to declare overloads with a new @overload tag.
|
||||
Each JSDoc comment with an @overload tag is treated as a distinct overload for the following function declaration.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {string} a
|
||||
* @param {string} b
|
||||
* @return {string}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {number} a
|
||||
* @param {number} b
|
||||
* @return {number}
|
||||
*/
|
||||
|
||||
function add(a: number | string, b: number | string) {
|
||||
if (typeof a === 'number' && typeof b === 'number') {
|
||||
return a + b;
|
||||
} else if (typeof a === 'string' && typeof b === 'string') {
|
||||
return a.concat(b);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.equal(add(1, 2), 3);
|
||||
Assert.equal(add('hello', 'world'), 'helloworld');
|
||||
Assert.equal(add('hello', 1), 0);
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 now allows JSDoc to declare overloads with a new @overload tag.
|
||||
Each JSDoc comment with an @overload tag is treated as a distinct overload for the following function declaration.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {string} a
|
||||
* @param {string} b
|
||||
* @return {string}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {number} a
|
||||
* @param {number} b
|
||||
* @return {number}
|
||||
*/
|
||||
|
||||
class printValue {
|
||||
overload(a: string | number, b: string | number) {
|
||||
if (typeof a === 'number' && typeof b === 'number') {
|
||||
return a + b;
|
||||
} else if (typeof a === 'string' && typeof b === 'string') {
|
||||
return a.concat(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let ol = new printValue();
|
||||
Assert.isUndefined(ol.overload('hello', 1));
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 now allows JSDoc to declare overloads with a new @overload tag.
|
||||
Each JSDoc comment with an @overload tag is treated as a distinct overload for the following function declaration.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {string} a
|
||||
* @return {string}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {string} a
|
||||
* @param {string} b
|
||||
*/
|
||||
|
||||
function printValue(a: string, b?: string) {
|
||||
if (b) {
|
||||
return a.concat(b);
|
||||
}
|
||||
else {
|
||||
return a.toUpperCase();
|
||||
}
|
||||
}
|
||||
Assert.equal(printValue('hello'), 'HELLO');
|
||||
Assert.equal(printValue('hello', 'world'), 'helloworld');
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 now allows JSDoc to declare overloads with a new @overload tag.
|
||||
Each JSDoc comment with an @overload tag is treated as a distinct overload for the following function declaration.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {string} a
|
||||
* @return {string}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {number} a
|
||||
* @param {number} b
|
||||
* @return {number}
|
||||
*/
|
||||
|
||||
function printValue(a: string | number, b?: number) {
|
||||
if (typeof a === 'number' && typeof b === 'number') {
|
||||
return a + b;
|
||||
}
|
||||
else {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.equal(printValue(1, 2), 3);
|
||||
Assert.equal(printValue('hello'), 'hello');
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 now allows JSDoc to declare overloads with a new @overload tag.
|
||||
Each JSDoc comment with an @overload tag is treated as a distinct overload for the following function declaration.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {string} a
|
||||
* @return {string}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {number} a
|
||||
* @param {number} b
|
||||
* @return {number}
|
||||
*/
|
||||
|
||||
class printValue {
|
||||
overload(a: string | number, b?: number) {
|
||||
if (typeof a === 'number' && typeof b === 'number') {
|
||||
return a + b;
|
||||
}
|
||||
else {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let ol = new printValue();
|
||||
Assert.equal(ol.overload(1, 2), 3);
|
||||
Assert.equal(ol.overload('hello'), 'hello');
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 now allows JSDoc to declare overloads with a new @overload tag.
|
||||
Each JSDoc comment with an @overload tag is treated as a distinct overload for the following function declaration.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {string} a
|
||||
* @param {string} b
|
||||
* @return {string}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {number} a
|
||||
* @param {number} b
|
||||
* @return {number}
|
||||
*/
|
||||
|
||||
class printValue {
|
||||
overload(a: string | number, b: string | number) {
|
||||
if (typeof a === 'number' && typeof b === 'number') {
|
||||
return a + b;
|
||||
} else if (typeof a === 'string' && typeof b === 'string') {
|
||||
return a.concat(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let ol = new printValue();
|
||||
Assert.equal(ol.overload(1, 2), 3);
|
||||
Assert.equal(ol.overload('hello', 'world'), 'helloworld');
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 now allows JSDoc to declare overloads with a new @overload tag.
|
||||
Each JSDoc comment with an @overload tag is treated as a distinct overload for the following function declaration.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {string} a
|
||||
* @return {string}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {string} a
|
||||
* @param {string} b
|
||||
* @return {string}
|
||||
*/
|
||||
|
||||
class printValue {
|
||||
overload(a: string, b?: string) {
|
||||
if (b) {
|
||||
return a.concat(b);
|
||||
}
|
||||
else {
|
||||
return a.toUpperCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let ol = new printValue();
|
||||
Assert.equal(ol.overload('hello'), 'HELLO');
|
||||
Assert.equal(ol.overload('hello', 'world'), 'helloworld');
|
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 now allows JSDoc to declare overloads with a new @overload tag.
|
||||
Each JSDoc comment with an @overload tag is treated as a distinct overload for the following function declaration.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {void} obj
|
||||
*/
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {Shape} obj
|
||||
*/
|
||||
|
||||
interface Shape {
|
||||
x: number;
|
||||
y: number;
|
||||
height: number;
|
||||
width: number;
|
||||
}
|
||||
|
||||
class Square {
|
||||
public x: number;
|
||||
public y: number;
|
||||
public height: number;
|
||||
public width: number;
|
||||
|
||||
constructor(obj?: Shape) {
|
||||
this.x = obj?.x ?? 0;
|
||||
this.y = obj?.y ?? 0;
|
||||
this.height = obj?.height ?? 0;
|
||||
this.width = obj?.width ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
let square: Square;
|
||||
square = new Square();
|
||||
square.x = 10;
|
||||
square.y = 50;
|
||||
square.height = 100;
|
||||
square.width = 100;
|
||||
|
||||
Assert.equal(square.x, 10);
|
||||
Assert.equal(square.y, 50);
|
||||
Assert.equal(square.height, 100);
|
||||
Assert.equal(square.width, 100);
|
||||
|
||||
let squareConfig: Shape;
|
||||
squareConfig = { x: 10, y: 50, height: 100, width: 100 };
|
||||
|
||||
let squareNew: Square;
|
||||
squareNew = new Square(squareConfig);
|
||||
|
||||
Assert.equal(squareNew.x, 10);
|
||||
Assert.equal(squareNew.y, 50);
|
||||
Assert.equal(squareNew.height, 100);
|
||||
Assert.equal(squareNew.width, 100);
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 now allows JSDoc to declare overloads with a new @overload tag.
|
||||
Each JSDoc comment with an @overload tag is treated as a distinct overload for the following function declaration.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {void} obj
|
||||
*/
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {any} obj
|
||||
*/
|
||||
|
||||
class Square {
|
||||
public x: number;
|
||||
public y: number;
|
||||
public height: number;
|
||||
public width: number;
|
||||
|
||||
constructor(obj?: any) {
|
||||
this.x = obj?.x ?? 0;
|
||||
this.y = obj?.y ?? 0;
|
||||
this.height = obj?.height ?? 0;
|
||||
this.width = obj?.width ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
let squareConfig: Square;
|
||||
squareConfig = new Square();
|
||||
squareConfig.x = 10;
|
||||
squareConfig.y = 50;
|
||||
squareConfig.height = 100;
|
||||
squareConfig.width = 100;
|
||||
|
||||
Assert.equal(squareConfig.x, 10);
|
||||
Assert.equal(squareConfig.y, 50);
|
||||
Assert.equal(squareConfig.height, 100);
|
||||
Assert.equal(squareConfig.width, 100);
|
||||
|
||||
let square: Square;
|
||||
square = new Square({ x: 10, y: 50, height: 100, width: 100 });
|
||||
|
||||
Assert.equal(square.x, 10);
|
||||
Assert.equal(square.y, 50);
|
||||
Assert.equal(square.height, 100);
|
||||
Assert.equal(square.width, 100);
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 now allows JSDoc to declare overloads with a new @overload tag.
|
||||
Each JSDoc comment with an @overload tag is treated as a distinct overload for the following function declaration.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {Shape} obj
|
||||
*/
|
||||
|
||||
/**
|
||||
* @overload
|
||||
* @param {any} obj
|
||||
*/
|
||||
|
||||
interface Shape {
|
||||
x: number;
|
||||
y: number;
|
||||
height: number;
|
||||
width: number;
|
||||
}
|
||||
|
||||
class Square {
|
||||
public x: number;
|
||||
public y: number;
|
||||
public height: number;
|
||||
public width: number;
|
||||
|
||||
constructor(obj: Shape) {
|
||||
this.x = obj?.x ?? 0;
|
||||
this.y = obj?.y ?? 0;
|
||||
this.height = obj?.height ?? 0;
|
||||
this.width = obj?.width ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
let squareConfig: Shape;
|
||||
squareConfig = { x: 10, y: 50, height: 100, width: 100 };
|
||||
|
||||
let square: Square;
|
||||
square = new Square(squareConfig);
|
||||
|
||||
Assert.equal(square.x, 10);
|
||||
Assert.equal(square.y, 50);
|
||||
Assert.equal(square.height, 100);
|
||||
Assert.equal(square.width, 100);
|
||||
|
||||
let square_any: Square;
|
||||
square_any = new Square({ x: 10, y: 50, height: 100, width: 100 });
|
||||
|
||||
Assert.equal(square_any.x, 10);
|
||||
Assert.equal(square_any.y, 50);
|
||||
Assert.equal(square_any.height, 100);
|
||||
Assert.equal(square_any.width, 100);
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
satisfies can catch type mismatches.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
// @ts-check
|
||||
/**
|
||||
* @typedef {Function} Greeter
|
||||
* @param {string} name
|
||||
* @return {string}
|
||||
*/
|
||||
|
||||
interface Greeter {
|
||||
greet(name: string): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @satisfies {Greeter}
|
||||
*/
|
||||
function greeter(name: string) {
|
||||
return ('Hello ' + name);
|
||||
}
|
||||
|
||||
const myGreeter = greeter('Jack');
|
||||
Assert.equal(myGreeter, 'Hello Jack');
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
satisfies can catch type mismatches.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
// @ts-check
|
||||
/**
|
||||
* @typedef { 'circle' | 'square' | 'triangle'} Shapes
|
||||
*/
|
||||
|
||||
/**
|
||||
* @satisfies {Record<Shapes, number | string>}
|
||||
*/
|
||||
const shapesInGraphic = {
|
||||
'circle': 4,
|
||||
'square': 'one',
|
||||
'triangle': 3
|
||||
};
|
||||
|
||||
Assert.equal(shapesInGraphic.square.toUpperCase(), 'ONE');
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
satisfies can catch type mismatches.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
// @ts-check
|
||||
/**
|
||||
* @satisfies { 'foo' | 'bar' }
|
||||
*/
|
||||
const messageRight = 'foo';
|
||||
Assert.equal(messageRight, 'foo');
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
satisfies can catch type mismatches.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
// @ts-check
|
||||
/**
|
||||
* @satisfies { 'foo' | 'bar' }
|
||||
*/
|
||||
const myMessage = 'bar';
|
||||
Assert.equal(myMessage, 'bar');
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
satisfies can catch type mismatches.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
type Colors = 'red' | 'green' | 'blue';
|
||||
|
||||
type RGB = [red: number, green: number, blue: number];
|
||||
|
||||
/**
|
||||
* @satisfies Colors | RGB
|
||||
*/
|
||||
const palette = {
|
||||
red: [255, 0, 0],
|
||||
green: '#00ff00',
|
||||
blue: [0, 0, 255]
|
||||
}
|
||||
|
||||
Assert.equal(palette.green, '#00ff00');
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
satisfies can catch type mismatches.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
// @ts-check
|
||||
/**
|
||||
* @typedef CompilerOptions
|
||||
* @prop {boolean} [strict]
|
||||
* @prop {string} [outDir]
|
||||
*/
|
||||
|
||||
/**
|
||||
* @satisfies {CompilerOptions}
|
||||
*/
|
||||
let myCompilerOptions = {
|
||||
strict: true,
|
||||
outDir: '../lib'
|
||||
};
|
||||
|
||||
Assert.equal(myCompilerOptions.strict, true);
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
satisfies can catch type mismatches.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
// @ts-check
|
||||
/**
|
||||
* @typedef CompilerOptions
|
||||
* @prop {boolean} [strict]
|
||||
* @prop {string} [outDir]
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef ConfigSettings
|
||||
* @prop {CompilerOptions} [compilerOptions]
|
||||
* @prop {string | string[]} [extends]
|
||||
*/
|
||||
|
||||
let myConfigSettings = /** @satisfies {ConfigSettings} */ {
|
||||
compilerOptions: {
|
||||
strict: true,
|
||||
outDir: '../lib'
|
||||
},
|
||||
extends: [
|
||||
'@tsconfig/strictest/tsconfig.json',
|
||||
'../../../tsconfig.base.json'
|
||||
]
|
||||
};
|
||||
|
||||
Assert.isTrue(myConfigSettings.compilerOptions.strict);
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
satisfies can catch type mismatches.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
// @ts-check
|
||||
/**
|
||||
* @typedef { 'hello world' | 'Hello, world' } WelcomeMessage
|
||||
*/
|
||||
|
||||
/** @satisfies { WelcomeMessage } */
|
||||
const message = 'hello world';
|
||||
Assert.equal(message, 'hello world');
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
satisfies can catch type mismatches.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
// @ts-check
|
||||
/**
|
||||
* @typedef { 'hello world' | 'Hello, world' } WelcomeMessage
|
||||
*/
|
||||
|
||||
/** @satisfies { WelcomeMessage } */
|
||||
const myMessage = 'Hello, world';
|
||||
Assert.equal(myMessage, 'Hello, world');
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
satisfies can catch type mismatches.
|
||||
module: ESNext
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
// @ts-check
|
||||
/**
|
||||
* @typedef { 'red' | 'green' | 'blue' } Colors
|
||||
* */
|
||||
|
||||
/**
|
||||
* @satisfies { Record<Colors, unknown> }
|
||||
*/
|
||||
const favoriteColors = {
|
||||
red: 'yes',
|
||||
green: false,
|
||||
blue: 'kinda'
|
||||
}
|
||||
|
||||
Assert.equal(favoriteColors.red, 'yes');
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
export class spaceShip {
|
||||
name = 'Star';
|
||||
|
||||
setName(myName: string) {
|
||||
this.name = myName;
|
||||
}
|
||||
|
||||
getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
export class shipString {
|
||||
ship = 'ship';
|
||||
|
||||
toUpper() {
|
||||
return this.ship.toUpperCase();
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
export type * as fac from './factory.js'
|
||||
export * from './factory.js'
|
||||
|
||||
export type * as vehicles from './vehicles.js'
|
||||
export * from './vehicles.js'
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
export class vehiclesFactory {
|
||||
name = 'Audi';
|
||||
|
||||
setName(myName: string) {
|
||||
this.name = myName;
|
||||
}
|
||||
|
||||
getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
export class myVehicles {
|
||||
myCar = 'alto';
|
||||
|
||||
toUpper() {
|
||||
return this.myCar.toUpperCase();
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
export class circleArea {
|
||||
radius = 2;
|
||||
PI = 3;
|
||||
|
||||
getArea() {
|
||||
return this.PI * this.radius * this.radius;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
export type * as circle from './circle.js'
|
||||
export * from './circle.js'
|
||||
|
||||
export type * as square from './square.js'
|
||||
export * from './square.js'
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
export class squareArea {
|
||||
length = 3;
|
||||
|
||||
getArea(){
|
||||
return this.length * this.length;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 support for export * as ns from "module" re-exports.
|
||||
module: es2020
|
||||
moduleResolution: nodenext
|
||||
target: es2021
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { fac, spaceShip } from './models/index.js'
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function takeASpaceship(s: fac.spaceShip) {
|
||||
Assert.equal(s.getName(), 'Star');
|
||||
}
|
||||
|
||||
const mySpaceship = new spaceShip();
|
||||
takeASpaceship(mySpaceship);
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 support for export * from "module" re-exports.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { spaceShip } from './models/index.js'
|
||||
import { circleArea } from './shap/index.js'
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
const mySpaceShip = new spaceShip();
|
||||
const myCirlceArea = new circleArea();
|
||||
|
||||
Assert.equal(mySpaceShip.getName(), 'Star');
|
||||
Assert.equal(myCirlceArea.getArea(), 12);
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 support for export * from "module" or export * as ns from "module" re-exports.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { fac, spaceShip, vehicles, vehiclesFactory } from './models/index.js'
|
||||
import { circle, circleArea, square, squareArea } from './shap/index.js'
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function takeASpaceship(s: fac.spaceShip) {
|
||||
Assert.equal(s.getName(), 'Star');
|
||||
}
|
||||
|
||||
function takeVehicles(s: vehicles.vehiclesFactory) {
|
||||
Assert.equal(s.getName(), 'Audi');
|
||||
}
|
||||
|
||||
function takeCircleArea(s: circle.circleArea) {
|
||||
Assert.equal(s.getArea(), 12);
|
||||
}
|
||||
|
||||
function takeSquareArea(s: square.squareArea) {
|
||||
Assert.equal(s.getArea(), 9);
|
||||
}
|
||||
|
||||
const mySpaceship = new spaceShip();
|
||||
const myVehicles = new vehiclesFactory();
|
||||
|
||||
takeASpaceship(mySpaceship);
|
||||
takeVehicles(myVehicles);
|
||||
|
||||
const myCirlceArea = new circleArea();
|
||||
const mySquareArea = new squareArea();
|
||||
|
||||
takeCircleArea(myCirlceArea);
|
||||
takeSquareArea(mySquareArea);
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 support for export * from "module" or export * as ns from "module" re-exports.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { spaceShip, vehiclesFactory } from './models/index.js'
|
||||
import { circleArea, squareArea } from './shap/index.js'
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
const mySpaceship = new spaceShip();
|
||||
const myVehicles = new vehiclesFactory();
|
||||
|
||||
Assert.equal(mySpaceship.getName(), 'Star');
|
||||
Assert.equal(myVehicles.getName(), 'Audi');
|
||||
|
||||
myVehicles.setName('car');
|
||||
Assert.equal(myVehicles.getName(), 'car');
|
||||
|
||||
const myCirlce = new circleArea();
|
||||
const mySqueare = new squareArea();
|
||||
|
||||
Assert.equal(myCirlce.getArea(), 12);
|
||||
Assert.equal(mySqueare.getArea(), 9);
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 support for export * from "module" re-exports.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { spaceShip } from './models/index.js'
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
const mySpaceShip = new spaceShip();
|
||||
Assert.equal(mySpaceShip.getName(), 'Star');
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 support for export * from "module" or export * as ns from "module" re-exports.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { fac, spaceShip, vehicles, vehiclesFactory } from './models/index.js'
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function takeASpaceship(s: fac.spaceShip) {
|
||||
Assert.equal(s.getName(), 'Star');
|
||||
}
|
||||
|
||||
function takeVehicles(s: vehicles.vehiclesFactory) {
|
||||
Assert.equal(s.getName(), 'Audi');
|
||||
}
|
||||
|
||||
const mySpaceship = new spaceShip();
|
||||
const myVehicles = new vehiclesFactory();
|
||||
|
||||
takeASpaceship(mySpaceship);
|
||||
takeVehicles(myVehicles);
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 support for export * from "module" or export * as ns from "module" re-exports.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { spaceShip, vehiclesFactory } from './models/index.js'
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
const mySpaceship = new spaceShip();
|
||||
const myVehicles = new vehiclesFactory();
|
||||
|
||||
Assert.equal(mySpaceship.getName(), 'Star');
|
||||
Assert.equal(myVehicles.getName(), 'Audi');
|
||||
|
||||
myVehicles.setName('car');
|
||||
Assert.equal(myVehicles.getName(), 'car');
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 support for export * as ns from "module" re-exports.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { fac, spaceShip, shipString } from './models/index.js'
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function takeASpaceship(s: fac.spaceShip, d: fac.shipString) {
|
||||
Assert.equal(s.getName(), 'Star');
|
||||
Assert.equal(d.toUpper(), 'SHIP');
|
||||
}
|
||||
|
||||
const mySpaceship = new spaceShip();
|
||||
const myShipString = new shipString();
|
||||
|
||||
takeASpaceship(mySpaceship, myShipString);
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 support for export * from "module" re-exports.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { spaceShip, shipString } from './models/index.js'
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
const mySpaceship = new spaceShip();
|
||||
const myShipString = new shipString();
|
||||
|
||||
Assert.equal(mySpaceship.getName(), 'Star');
|
||||
Assert.equal(myShipString.toUpper(), 'SHIP');
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 support for export * as ns from "module" re-exports.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { fac, spaceShip, shipString, vehicles, vehiclesFactory, myVehicles } from './models/index.js'
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function takeASpaceship(s: fac.spaceShip, d: fac.shipString) {
|
||||
Assert.equal(s.getName(), 'Star');
|
||||
Assert.equal(d.toUpper(), 'SHIP');
|
||||
}
|
||||
|
||||
function takeVehicles(s: vehicles.vehiclesFactory, d: vehicles.myVehicles) {
|
||||
Assert.equal(s.getName(), 'Audi');
|
||||
Assert.equal(d.myCar, 'alto');
|
||||
}
|
||||
|
||||
const mySpaceship = new spaceShip();
|
||||
const myShipString = new shipString();
|
||||
takeASpaceship(mySpaceship, myShipString);
|
||||
|
||||
const myCar = new vehiclesFactory();
|
||||
const myCarToUpper = new myVehicles();
|
||||
takeVehicles(myCar, myCarToUpper);
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 support for export * from "module" re-exports.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { spaceShip, shipString, vehiclesFactory, myVehicles } from './models/index.js'
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
const mySpaceship = new spaceShip();
|
||||
const myShipString = new shipString();
|
||||
|
||||
Assert.equal(mySpaceship.getName(), 'Star');
|
||||
Assert.equal(myShipString.toUpper(), 'SHIP');
|
||||
|
||||
const vehicles = new vehiclesFactory();
|
||||
const myCar = new myVehicles();
|
||||
|
||||
Assert.equal(vehicles.getName(), 'Audi');
|
||||
Assert.equal(myCar.toUpper(), 'ALTO');
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**---
|
||||
description: >
|
||||
TypeScript 5.0 support for export * as ns from "module" re-exports.
|
||||
module: ES2022
|
||||
isCurrent: true
|
||||
---*/
|
||||
|
||||
|
||||
import { fac, spaceShip } from './models/index.js'
|
||||
import { circle, circleArea } from './shap/index.js'
|
||||
import { Assert } from '../../../suite/assert.js'
|
||||
|
||||
function takeASpaceship(s: fac.spaceShip) {
|
||||
Assert.equal(s.getName(), 'Star');
|
||||
}
|
||||
|
||||
function getMyCirlceArea(s: circle.circleArea) {
|
||||
Assert.equal(s.getArea(), 12);
|
||||
}
|
||||
|
||||
const mySpaceship = new spaceShip();
|
||||
const myCirlceArea = new circleArea();
|
||||
|
||||
takeASpaceship(mySpaceship);
|
||||
getMyCirlceArea(myCirlceArea);
|
Loading…
Reference in New Issue
Block a user