• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16function foo<T>(t: T | {}, k: keyof (T | {})) {}
17
18class ObservableImpl<T> extends Observable<T> {
19  extendObservable<U extends object>(extraProps: U) {
20    new ObservableImpl<{ [K in keyof (T & U)]: (T & U)[K] }>();
21 }
22}
23
24type NestedKey<T, K extends keyof T> = T[K] extends object ? keyof T[K] : never;
25
26/* @@? 16:24 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */
27/* @@? 16:42 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */
28/* @@? 16:45 Error TypeError: The `keyof` keyword can only be used for class or interface type. */
29/* @@? 18:33 Error TypeError: Cannot find type 'Observable'. */
30/* @@? 18:33 Error TypeError: The super type of 'ObservableImpl' class is not extensible. */
31/* @@? 20:24 Error SyntaxError: Using object literals to declare types in place is not supported. Please declare types and interfaces explicitly! */
32/* @@? 20:27 Error SyntaxError: Unexpected token 'K'. */
33/* @@? 20:32 Error SyntaxError: Field type annotation expected. */
34/* @@? 20:41 Error SyntaxError: Unexpected token '&'. */
35/* @@? 20:41 Error SyntaxError: Unexpected token, expected ',' or ')'. */
36/* @@? 20:41 Error SyntaxError: Parameter declaration should have an explicit type annotation. */
37/* @@? 20:44 Error SyntaxError: Field type annotation expected. */
38/* @@? 20:44 Error SyntaxError: Unexpected token ')'. */
39/* @@? 20:45 Error SyntaxError: Unexpected token ']'. */
40/* @@? 20:46 Error SyntaxError: Unexpected token ':'. */
41/* @@? 20:48 Error SyntaxError: Unexpected token '('. */
42/* @@? 20:51 Error SyntaxError: Field type annotation expected. */
43/* @@? 20:51 Error SyntaxError: Unexpected token '&'. */
44/* @@? 20:54 Error SyntaxError: Field type annotation expected. */
45/* @@? 20:54 Error SyntaxError: Unexpected token ')'. */
46/* @@? 20:56 Error SyntaxError: Unexpected token 'K'. */
47/* @@? 20:57 Error SyntaxError: Unexpected token ']'. */
48/* @@? 24:36 Error TypeError: The `keyof` keyword can only be used for class or interface type. */
49/* @@? 24:42 Error SyntaxError: Unexpected token, expected ']'. */
50/* @@? 24:42 Error SyntaxError: Unexpected token ']'. */
51/* @@? 24:43 Error SyntaxError: Unexpected token ']'. */
52/* @@? 24:45 Error SyntaxError: Unexpected token 'extends'. */
53/* @@? 24:53 Error SyntaxError: Unexpected token 'object'. */
54/* @@? 24:53 Error TypeError: Type name 'object' used in the wrong context */
55/* @@? 24:62 Error TypeError: Unresolved reference keyof */
56/* @@? 24:68 Error SyntaxError: Unexpected token. */
57/* @@? 24:68 Error TypeError: Unresolved reference T */
58/* @@? 24:68 Error TypeError: Indexed access is not supported for such expression type. */
59/* @@? 24:70 Error SyntaxError: Unexpected token, expected ']'. */
60/* @@? 24:73 Error SyntaxError: Unexpected token ':'. */
61/* @@? 24:75 Error SyntaxError: Unexpected token 'never'. */
62/* @@? 24:75 Error TypeError: Class name 'never' used in the wrong context */
63