elision

Do I need to use the “import type” feature of TypeScript 3.8 if all of my imports are from my own file?

烂漫一生 提交于 2021-02-19 02:15:44
问题 I have a simple file types.ts that defines some types: export interface MyInterface { // ... } export const enum MyEnum { // ... } export type MyType = { // ... } I have read about the new feature import type for the latest typescript here. As far as I understand it is meant to fix specific problems which seems mostly to happen when importing from .js files. I can import my types with both import and import type statements. Both seems to work equally fine. The question is should I prefer

Do I need to use the “import type” feature of TypeScript 3.8 if all of my imports are from my own file?

房东的猫 提交于 2021-02-19 02:10:30
问题 I have a simple file types.ts that defines some types: export interface MyInterface { // ... } export const enum MyEnum { // ... } export type MyType = { // ... } I have read about the new feature import type for the latest typescript here. As far as I understand it is meant to fix specific problems which seems mostly to happen when importing from .js files. I can import my types with both import and import type statements. Both seems to work equally fine. The question is should I prefer

Do I need to use the “import type” feature of TypeScript 3.8 if all of my imports are from my own file?

久未见 提交于 2021-02-19 02:09:39
问题 I have a simple file types.ts that defines some types: export interface MyInterface { // ... } export const enum MyEnum { // ... } export type MyType = { // ... } I have read about the new feature import type for the latest typescript here. As far as I understand it is meant to fix specific problems which seems mostly to happen when importing from .js files. I can import my types with both import and import type statements. Both seems to work equally fine. The question is should I prefer

Is this “elision failure” language-mandated?

自闭症网瘾萝莉.ら 提交于 2020-04-13 03:53:08
问题 Consider the following code: #include <utility> #include <string> int bar() { std::pair<int, std::string> p { 123, "Hey... no small-string optimization for me please!" }; return p.first; } (simplified thanks to @Jarod42 :-) ...) I expect the function to be implemented as simply: bar(): mov eax, 123 ret but instead, the implementation calls operator new() , constructs an std::string with my literal, then calls operator delete() . At least - that's what gcc 9 and clang 9 do (GodBolt). Here's